home *** CD-ROM | disk | FTP | other *** search
- program TestClone; {Quick Pascal Version}
-
- uses CRT,UObj;
-
- type
- Ancestor = object(TObj)
- procedure WhoAmI;
- end;
-
- procedure Ancestor.WhoAmI;
- begin
- Writeln('Ancestor');
- end;
-
- type
- Child = object(Ancestor)
- procedure WhoAmI; override;
- end;
-
- procedure Child.WhoAmI;
- begin
- Writeln('Child');
- end;
-
- var
- theAncestor : Ancestor;
- theChild : Child;
- theClone : Ancestor;
-
- begin
- ClrScr;
-
- New(theAncestor);
- New(theChild);
-
- theClone := theChild.Clone;
- theChild.WhoAmI;
- theClone.WhoAmI;
- theClone.Free;
-
- writeln;
-
- theClone := theAncestor.Clone;
- theAncestor.WhoAmI;
- theClone.WhoAmI;
- theClone.Free;
-
- theAncestor.Free;
- theChild.Free;
- end.
-